 /**
 * v-drag 拖拽
 */
 
export default {
  mounted(el, binding, vnode) {
    el.onmouseover = function (e) {
      if (el === e.target) {
        this.style.cursor = 'move'
      } else {
        this.style.cursor = 'default'
      }
    }
    el.onmousedown = function (e) {
      if (el === e.target) {
        var disx = e.pageX - el.offsetLeft
        var disy = e.pageY - el.offsetTop
        document.onmousemove = function (e) {
          el.style.left = e.pageX - disx + 'px'
          el.style.top = e.pageY - disy + 'px'
        }
        document.onmouseup = function () {
          document.onmousemove = document.onmouseup = null
        }
      }
    }
  }
}
